#include <Windows.h>
#include "tppCamera.h"
#include <gl\GLU.h>

//------------------------------------------------ ApplyCameraTransform ------------------------------------------//
void TPPCamera::ApplyCameraTransform()
{
	if( isEnabled )
	{
		//uklad kamery identyczny z ukladem obiektu
		camera = (*objectToFollow);

		//cofamy kamere do tylu i unosimy do gory
		camera.TranslateAlongZ( -distanceOnZ );
		camera.TranslateAlongY( distanceOnY );

		//nachylame kamere
		camera.RotateLocalX( inclination );

		//kamera ustawiona - wywolujemy gluLookAt
		V3 origin = camera.GetOrigin();
		V3 forward = camera.GetForwardVector();
		V3 up = camera.GetUpVector();

		gluLookAt(  origin.get(1), origin.get(2), origin.get(3), //wspolrzedne oka
					origin.get(1) + forward.get(1),				//wektor wzdluz ktorego spogladmy
					origin.get(2) + forward.get(2), 
					origin.get(3) + forward.get(3), 
					up.get(1), up.get(2), up.get(3)				//wektor do gory
				 );
	}
		
}